home *** CD-ROM | disk | FTP | other *** search
- Path: chronicle.mti.sgi.com!news
- From: austern@isolde.mti.sgi.com (Matt Austern)
- Newsgroups: comp.lang.c++,comp.lang.c
- Subject: Re: Performance: C vs. C++
- Date: 15 Feb 1996 23:04:52 GMT
- Organization: SGI
- Message-ID: <AUSTERN.96Feb15150452@isolde.mti.sgi.com>
- References: <30F6BAAC.12B5@iastate.edu> <4da9pn$a45@news.bridge.net>
- <AUSTERN.96Feb15134314@isolde.mti.sgi.com>
- <4g0cgt$a3l@stc06.ctd.ornl.gov>
- Reply-To: austern@mti.sgi.com
- NNTP-Posting-Host: isolde.mti.sgi.com
- In-reply-to: kennel@msr.epm.ornl.gov's message of 15 Feb 1996 22:36:13 GMT
-
- In article <4g0cgt$a3l@stc06.ctd.ornl.gov> kennel@msr.epm.ornl.gov (Matt Kennel) writes:
-
- > > And if you do have a pointer to a polymorphic class, and you want to
- > > call a virtual function and ensure that you're calling the base
- > > class's version, that's actually possible: instead of writing
- > > base_pointer->f(), you write base_pointer->base::f(). The syntax
- > > is ugly, to be sure, but it doesn't bother me that you have to use
- > > ugly syntax for such a rare operation.
- >
- > Does it work with []??
- >
- > I.e.
- >
- > MyMatrix x;
- >
- > x[3][2] = 4;
-
- Yes, but only at the cost of even uglier syntax. I'm going to pretend
- that matrix reference is x(3,2) instead of x[3][2]: you need to jump
- through too many hoops if you want to use the x[3][2] form. (For
- those who aren't C++ experts, what you have to do is define an
- auxiliary class.)
-
- If x is a reference to a polymorphic base class MatrixBase, and
- if operator() is a virtual function, then you can call the base
- class version explicitly by writing
- x.MatrixBase::operator()(3,2) = 4.
-
- In general, x(3,2) is equivalent to x.operator()(3,2). It's only when
- you're performing unusual operations, though (like suppressing
- run-time dispatch of a virtual function), that you need to write out
- x.operator()(3,2) explicitly.
- --
- Matt Austern
- SGI: MTI Compilers Group
- austern@isolde.mti.sgi.com
-